﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;





namespace HA.Data
{
    /// <summary>
    /// 错误检查模块
    /// </summary>
   public class CheckModel
   {

       #region 构造函数
       public CheckModel(CheckModelType checkModelType, Project project)
       {

           _project = project;

           this._currentCheckModelType = checkModelType;

           if (this._checkResult != null)
           {
               this._checkResult.Clear();
           }
           else
           {
               this._checkResult = new List<CheckResultMessage>();
           }

           if (_displaySetup==null )
           {
               _displaySetup = new ListDisplaySetup();
           }



       }

       #endregion


       #region 字段属性


       Project _project;


       ListDisplaySetup _displaySetup;

       public ListDisplaySetup DisplaySetup
       {
           get { return _displaySetup; }
           set { _displaySetup = value; }
       }


       CheckModelType _currentCheckModelType = CheckModelType.ModflowSimulation;



       List<CheckResultMessage> _checkResult;

       public List<CheckResultMessage> CheckResult
       {
           get { return _checkResult; }
           set { _checkResult = value; }
       }




       #endregion


       #region 共有方法

       public bool CheckModelData()
       {

           //try
           //{
               if (this._checkResult != null)
               {
                   this._checkResult.Clear();
               }
               else
               {
                   this._checkResult = new List<CheckResultMessage>();
               }
               if (_displaySetup == null)
               {
                   _displaySetup = new ListDisplaySetup();
               }

               if (_project != null)
               {


                   switch (this._currentCheckModelType)
                   {
                       case CheckModelType.ModflowSimulation:

                           if (_project.MfData != null)
                           {
                               ModelFacotry checkModel = new CheckModflow(_project.MfData);                              
                               _checkResult = checkModel.CheckModelData(this._displaySetup);

                           }


                           break;
                       case CheckModelType.Mt3dSimulation:

                           if (_project.Mt3dmsData != null)
                           {

                               ModelFacotry checkModel = new CheckMT3D(_project.Mt3dmsData);

                               _checkResult = checkModel.CheckModelData(this._displaySetup);

                           }


                           break;
                       default:
                           break;
                   }

                   return true;
               }
               else
               {
                   return false;
               }
        
              
           //}
           //catch 
           //{

           //    if (this._checkResult != null)
           //    {
           //        this._checkResult.Clear();
           //    }
           //    else
           //    {
           //        this._checkResult = new List<CheckResultMessage>();
           //    }


           //    return false;
           //}


       }


       #endregion




   }
}
